class Solution:
    def numberOfAlternatingGroups(self, colors: list[int]) -> int:
        n = len(colors)
        cnt = 0
        for i in range(n):
            if colors[i-2] != colors[i-1] and colors[i-1] != colors[i]:
                cnt += 1
        return cnt

if __name__ == '__main__':
    s = Solution()
    print(s.numberOfAlternatingGroups([1,1,1]))
    print(s.numberOfAlternatingGroups([0,1,0,0,1]))